import akshare as ak
import csv
import pandas as pd

def read_fundprice_by_ak(code):
    df1 = ak.fund_open_fund_info_em(code, indicator="单位净值走势")
    df1.columns=['日期', '单位净值走势', '日增长率']
    df2 = ak.fund_open_fund_info_em(code, indicator="累计净值走势")
    df2.columns=['日期', '累计净值走势']
    df = pd.merge(df1, df2, how='left', on='日期')

    print(len(df))

    data = []
    for i in range(0, len(df)):
        data.append([str(df.iloc[i]['日期'])+" 00:00:00", str(df.iloc[i]['单位净值走势']), str(df.iloc[i]['累计净值走势'])])

    fileName = './' + code + ".csv"
    with open(fileName,'w', newline = '') as file:
        writer = csv.writer(file, delimiter=',')
        writer.writerows(data)
        #log("write " + fileName + " success")
    return

read_fundprice_by_ak("005765")